package com.dong.rabbitmq.utils;

/**
 * 睡眠工具类
 *
 * @author dongjian
 */
public class SleepUtil {

    public static final ThreadLocal<Long> threadLocal = new ThreadLocal<Long>();

    /**
     * 线程睡眠方法
     *
     * @param second 秒
     */
    public static void sleep(int second) {

        try {
            Thread.sleep(1000 * second);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }

    /**
     * 记录开始时间
     */
    public static void begin() {
        threadLocal.set(System.currentTimeMillis());
    }
    /**
     * 计算执行时间 ms
     * @return
     */
    public static long comPutTime() {
        return (System.currentTimeMillis() - threadLocal.get());
    }
}
